﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm5 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bindgvPerson();
            }
        }

        private void bindgvPerson()
        {
            List<Person> personList = new List<Person>(){
                new Person(){ UserNum="20091041",UserName="张三", UserAge=20},
                new Person(){ UserNum="20091042",UserName="李四", UserAge=21},
                new Person(){ UserNum="20091043",UserName="王武", UserAge=22},
                new Person(){ UserNum="20091044",UserName="赵六", UserAge=23}
            };
            gvPerson.DataSource = personList;
            gvPerson.DataBind();

        }

        protected void gvPerson_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            
        }

        protected void gvPerson_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //鼠标悬停变色，鼠标移开恢复颜色
                //e.Row.Attributes.Add("onmouseover", "oldBG=this.style.backgroundColor; this.style.backgroundColor='#ff5599';");
                //e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=oldBG");
                /////双击行，改变该行颜色
               // e.Row.Attributes.Add("ondblclick", "this.style.backgroundColor='#aaffff';");
                //this.ClientScript.RegisterStartupScript(this.GetType(), "myclick", "javaScript:showFloat();", true);
           
            }
        }

        protected void gvPerson_RowCreated(object sender, GridViewRowEventArgs e)
        {

        }
        protected void BttLogin_Click(object sender, EventArgs e)
        {
            Server.Transfer(string.Format("WebForm2.aspx?ID={0}&Pwd={1}", TxtUserName.Value.Trim(), TxtUserPwd.Value.Trim()));
        }

    }
}